import JSEncrypt from 'jsencrypt';

//公钥
const publicKey: string =
  'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAzdeUIYBLJni9vjzsjh7X\n' +
  'jKHoLLGLl6mPeg/bQd59+iptjFr9oxEreZen1uexfgE8ktL0XW38Fwo7HUW4VQ/7\n' +
  'GdfuIDY61pjnrcV0gAoWXHSruhTO4W5LME5NcQuKX0kNOeA8u0WcRNhmXNpbu8fw\n' +
  '/8SCwNqOLRV+OJ9KlK56YlAv7D40UNMYYl9zEJMC4B/hHhMMdj7ffG3FaZ45XhJ1\n' +
  '1N03GrkLdnZqyhWD/SDpioD6OGRJY5tfC1Pxo4tUz6cMXxwctDUivid7z1TeGKIq\n' +
  'iVVKMVI2A73svHW2bDrAKrzRxnm9tU4nEH2hBlyZqNJBfcAFXcRDDadC8tWx74U5\n' +
  '2wIDAQAB';

// 公钥加密
export const encrypt= (txt: string): string | false => {
  const encryptor = new JSEncrypt();
  encryptor.setPublicKey(publicKey); // 设置公钥
  return encryptor.encrypt(txt); // 对数据进行加密
};

// 解密
// export function decrypt(txt) {
//     const encryptor = new JSEncrypt()
//     encryptor.setPrivateKey(privateKey) // 设置私钥
//     return encryptor.decrypt(txt) // 对数据进行解密
// }
